package com.lvw.weather.forcast.component;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.Random;

@Component
public class Sender {

    public static final Logger log = LoggerFactory.getLogger(Sender.class);

    @Autowired
    RabbitTemplate rabbitTemplate;

    public void send() {

        String context = "Today's PM2.5 : " + new Random().nextInt(500);

        log.info("===> Sending message: " + context);

        rabbitTemplate.convertAndSend("hello", context);

    }
}
